using System;
using System.Windows.Data;

namespace MeetCommon.Tools
{
	[ValueConversion(typeof(object), typeof(string))]
	public class DateTimeFormattingBindConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			string format = parameter as string;
			string valueString = value as string;
			if (format != null && valueString != null)
			{
				DateTime dtValue = DateTime.Parse(valueString);
				return dtValue.ToString(format);
			}
			else
				return value.ToString();
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return null;
		}
	}
}
